//
//  StoreDetailPackageCollectionCell.m
//  BaseProject
//
//  Created by 王洋 on 2020/7/2.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "StoreDetailPackageCollectionCell.h"

@implementation StoreDetailPackageCollectionCell


- (void)fillCellWithModel:(CommonPackageModel *)model {
    
    [self.mainImageView sd_setImageWithURL:[NSURL URLWithString:model.url] placeholderImage:[UIImage imageNamed:@"placeholder"] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
        if (image) {
         
            if (cacheType != SDImageCacheTypeMemory) {
                [UIView transitionWithView:self.mainImageView duration:0.61 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{
                    [self.mainImageView setImage:image];
                    self.mainImageView.alpha = 1.0;
                } completion:nil];
            } else {
                self.mainImageView.alpha = 1.0;
                [self.mainImageView setImage:image];
            }
        }
    }];
    self.mainTitle.text = model.goodsName;
    self.priceLab.text = [Utilities changeDoubleToString:model.goodsActivePrice];
    
    if (model.goodsClickCount > 0) {
        self.countLab.text = [NSString stringWithFormat:@"%ld",model.goodsClickCount];
    } else {
        self.countLab.text = @"999";
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];


//    [self.mainImageView sd_setImageWithURL:[NSURL URLWithString:@"https://ss0.bdstatic.com/70cFvHSh_Q1YnxGkpoWK1HF6hhy/it/u=2295461499,998239425&fm=26&gp=0.jpg"]];

    self.labTag1.layer.cornerRadius = 2;
    self.labTag1.layer.borderWidth = 1.0f;
    self.labTag1.layer.borderColor = UIColorHex(0xd2d2d2).CGColor;
    
    self.labTag2.layer.cornerRadius = 2;
    self.labTag2.layer.borderWidth = 1.0f;
    self.labTag2.layer.borderColor = UIColorHex(0xd2d2d2).CGColor;

}

- (void)layoutSubviews {
    [super layoutSubviews];
    
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.01 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        
        [self pp_clipCorners:UIRectCornerAllCorners radius:6 border:0.5 color:UIColorHex(0xf1f1f1)];

    });
}

@end
